package com.zang.singleton;

import com.zang.concurrent.collections.ThreadPool;

import java.util.concurrent.ExecutorService;

/**
 * 枚举单例模式
 *
 * @author Zhang Qiang
 * @Date 2019/9/21 17:04
 */
public class SingletonEnumBaseExample {

    public static void main(String[] args) {

        ExecutorService cachedThreadPool = ThreadPool.getPool().get("cachedThreadPool");

        cachedThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                SingletonEnum.INSTANCE.someEvent();
            }
        });
        cachedThreadPool.shutdown();

    }

    enum SingletonEnum{
        /**
         * 相当于其的唯一实例
         */
        INSTANCE;
        SingletonEnum(){}

        public void someEvent(){
            System.out.println("do something ... ");
        }

    }



}
